/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>Project: jse2204 - Stream4
 * <p>Powered by webrx On 2022-09-28 16:51:20
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Stream4 {
    public static void main(String[] args) {
        List<String> str = new ArrayList<>(List.of("mysql","java-jav32a","myjava","jav2afasscript","html","javacc"));
        //判断一下集合是不是每个元素有包含java字符串
        //boolean f = true;
        //for(int i=0;i<str.size();i++){
        //    if(!str.get(i).contains("java")){
        //        f = false;
        //        break;
        //    }
        //}
        //System.out.println(f);

        //allMatch() 返回true falce
        //boolean f = str.stream().allMatch(e -> e.contains("java"));
        //System.out.println(f);

        //anyMatch()
        //System.out.println(str.stream().anyMatch(e -> e.contains("java")));

        //noneMatch()
        //System.out.println(str.stream().noneMatch(e -> e.contains("java")));
        //System.out.println(str.stream().allMatch(e -> !e.contains("java")));

        System.out.println(str.stream().parallel().filter(e->Math.random()>.5).findFirst().get());
        System.out.println(str.stream().parallel().filter(e->Math.random()>.5).findAny().get());


    }
}
